import Router from 'koa-router'
// 格式转换
import IndexCon from '@/business/controller'
import {
  getListMid,
  getAddMid,
  getDetailMid,
  putMid,
  delMid,
  exportMid,
  getListParamMid,
  getAddBatchMid,
  uploadIniMid
} from '@/business/middleware/equipment/jiaoyantable.middleware'
import { addEditSchema, judgeIdSchema } from '@/business/schema'
import { exportExcelMid , exportExcelByQueryParamMid,formatHandle } from '@/business/middleware/common/common.middleware'
import JiaoyanjieguoTable from '@/mysql/model/equipment/jiaoyantable.model'
import { exportExcelSer,queryConditionsData } from '@/business/service'
import { addJudg, putJudg } from '@/business/schema/equipment/jiaoyantable.schema'
import { hasPermi } from '@/business/middleware/common/auth'

const router = new Router({ prefix: '/equipment' })
// 查询列表
router.get('/jiaoyantable/list', hasPermi('home:list'), getListMid, formatHandle, IndexCon())


 
// 新增
router.post(
  '/jiaoyantable',
  hasPermi('home:list'),
  addEditSchema(addJudg),
  getAddMid,
  IndexCon()
)
// 批量新增
router.post(
  '/jiaoyantable/batch',
  hasPermi('home:list'),
  // addEditSchema(addJudg),
  getAddBatchMid,
  IndexCon()
)
// 删除
router.delete('/jiaoyantable/:id', hasPermi('home:list'), judgeIdSchema(), delMid, IndexCon())

// 获取详细数据
router.get('/jiaoyantable/detail/:id', hasPermi('home:list'), judgeIdSchema(), getDetailMid, formatHandle, IndexCon())

// 修改
router.put(
  '/jiaoyantable',
  hasPermi('home:list'),
  addEditSchema(putJudg),

  putMid,
  IndexCon()
)

// 导出列表(excel)
router.post(
  '/jiaoyantable/export',
  hasPermi('home:list'),
  getListParamMid,
  exportExcelByQueryParamMid(queryConditionsData, JiaoyanjieguoTable, {'check_result':'check_result'}),
  exportMid,
  IndexCon()
)

// 上传
router.post('/jiaoyantable/import', hasPermi('home:list'), uploadIniMid, IndexCon('用户上传ini成功'));
export default router